package com.yonyou.cyxdms.basedata.service.controller.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoleilu.hutool.lang.Assert;
import com.yonyou.cyx.framework.bean.dto.framework.RestResultResponse;
import com.yonyou.cyxdms.basedata.client.domains.vo.VehicleInfoVO;
import com.yonyou.cyxdms.basedata.client.dto.product.TtVsPlanTemplateDTO;
import com.yonyou.cyxdms.basedata.client.dto.product.VehicleInfoDTO;
import com.yonyou.cyxdms.basedata.client.dto.wholesales.PlanTemplateDTO;
import com.yonyou.cyxdms.basedata.service.dto.DirectivePriceDTO;
import com.yonyou.cyxdms.basedata.service.dto.outapi.CmsApp04;
import com.yonyou.cyxdms.basedata.service.dto.outapi.CmsApp04QueryDto;
import com.yonyou.cyxdms.basedata.service.service.product.VsProductService;
import com.yonyou.cyxdms.basedata.service.vo.SalesGuidancePriceVO;
import com.yonyou.cyxdms.basedata.service.vo.productinfo.VsProductVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 定义车辆产品
 *
 * @author renwd
 * @since 2019/1/18
 */

@Api(value = "车辆产品接口", tags = {"车辆产品接口"})
@RestController
@RequestMapping("/vsProduct")
public class VsProductController {

    @Autowired
    private VsProductService vsProductService;

    /**
     * 根据五级车型查询销售指导价
     *
     * @param directivePriceDTO
     * @return com.yonyou.cyxdms.basedata.service.entity.product.SalesGuidancePriceVO
     * @author renwd
     * @since 2019/2/20
     */
    @ApiOperation(value = "查询销售指导价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/selectDirectivePrice")
    public SalesGuidancePriceVO selectDirectivePrice(DirectivePriceDTO directivePriceDTO) {
        return vsProductService.selectDirectivePrice(directivePriceDTO);
    }

    /**
     * 根据productId查询销售指导价
     *
     * @param productId
     * @return
     * @author ysj
     * @date 2019/09/16
     */
    @ApiOperation(value = "根据PRODUCT_ID查询销售指导价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/selectDirectivePriceByProductId")
    public SalesGuidancePriceVO selectDirectivePriceByProductId(@ApiParam(name = "productId", value = "产品ID") @RequestParam("productId") Long productId) {
        return vsProductService.selectDirectivePriceByProductId(productId);
    }

    /**
     * 根据名称查询产品配置ID
     *
     * @param vehicleInfoDTO
     * @return
     * @author ysj
     * @date 2019/10/21
     */
    @ApiOperation(value = "根据名称查询产品配置ID")
    @GetMapping("/getVehicleInfoByName")
    public VehicleInfoVO getVehicleInfoByName(VehicleInfoDTO vehicleInfoDTO) {
        return vsProductService.getVehicleInfoByName(vehicleInfoDTO);
    }

    /**
     * 通过产品代码查出productIds
     *
     * @param productCode
     * @return java.util.List<java.lang.Long>
     * @author dengqiang
     * @since 2019/10/22
     */
    @GetMapping("/queryProductIdsByProductCode")
    @ApiOperation(notes = "通过产品代码查出productIds", value = "通过产品代码查出productIds")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<Long> queryProductIdsBy(@RequestParam("productCode") String productCode) {
        return vsProductService.queryProductIdsBy(productCode);
    }

    /**
     * 根据appId查询所有产品
     */
    @GetMapping("/getAllProductByAppId")
    public List<VsProductVO> getAllProductByAppId(@RequestParam("appId") String appId) {
        return vsProductService.getAllProductByAppId(appId);
    }

    /**
     * 获取需求计划模板信息列表
     *
     * @param productCodes 产品代码
     * @author lyz
     * @date 2020/11/10
     */
    @PostMapping("/getPlanTemplates")
    public List<PlanTemplateDTO> getPlanTemplates(@RequestParam("productCodes") List<String> productCodes) {
        Assert.notEmpty(productCodes, "产品代码必传");
        return vsProductService.getPlanTemplates(productCodes);
    }


    /**
     * CmsApp04接口
     *
     * @param cmsApp04QueryDto 查询条件
     * @author  xyy
     * @date  2021/01/19
     */
    @PostMapping("/searchCmsApp04Data")
    public CmsApp04 searchCmsApp04Data(CmsApp04QueryDto cmsApp04QueryDto) {

        return vsProductService.searchCmsApp04Data(cmsApp04QueryDto);
    }


    @PostMapping("/queryCarListSideC")
    public IPage<TtVsPlanTemplateDTO> queryCarListSideC(@RequestBody TtVsPlanTemplateDTO dto){
        Page<TtVsPlanTemplateDTO> page = new Page<>(dto.getCurrent(), dto.getSize());
        return vsProductService.queryCarListSideC(page,dto);
    }
    @PostMapping("/queryPlan1DetailProductInfo")
    public List<TtVsPlanTemplateDTO> queryPlan1DetailProductInfo(@RequestBody List<String> cdtos){
        return vsProductService.queryPlan1DetailProductInfo(cdtos);
    }
}
